package com.repair.mapper;

import com.repair.entity.AnnouncementRead;
import org.apache.ibatis.annotations.*;

@Mapper
public interface AnnouncementReadMapper {
    
    @Insert("INSERT INTO announcement_read (announcement_id, user_id) " +
            "VALUES (#{announcementId}, #{userId})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(AnnouncementRead announcementRead);
    
    @Select("SELECT COUNT(*) FROM announcement_read " +
            "WHERE announcement_id = #{announcementId} AND user_id = #{userId}")
    int countByAnnouncementAndUser(@Param("announcementId") Long announcementId, 
                                 @Param("userId") Long userId);
} 